Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FED-570 Unify package rename codemod #251

Merged
merged 31 commits into from
Oct 31, 2023

Conversation

sydneyjodon-wk
Copy link
Contributor

@sydneyjodon-wk sydneyjodon-wk commented Oct 12, 2023

Motivation

Codemod to migrate react_material_ui usages to unify_ui.

Changes

The codemod goes through the following process:

  • Updates bundle references to unify-ui
  • Runs UnifyRenameSuggestor:
    • Updates mui namespace usages to unify (also updates the alpha versions)
    • Renames any component or object usages that have new names in unify_ui
    • Migrates WSD ButtonColor usages to WsdButtonColor
    • Adds fixme comments for alerts, linearprogress, and badge
  • Updates imports
    • Any special case imports where the paths are different
    • Adds wsd.dart entrypoint imports as needed
    • Removes any unused imports

Release Notes

Review

See CONTRIBUTING.md for more details on review types (+1 / QA +1 / +10) and code review process.

Please review:

QA Checklist

  • Tests were updated and provide good coverage of the changeset and other affected code
  • Manual testing was performed if needed
    • Steps from PR author:
      • Verify good test coverage
      • Verify that the codemod does everything we'd expect it to do for the rename
      • Test the codemod on some other repos:
        • Checkout this branch locally
        • Run in the repo being tested:
          • dart pub global activate -s path ../over_react_codemod
          • dart pub global run over_react_codemod:unify_package_rename --yes-to-all
    • Anything falling under manual testing criteria outlined in CONTRIBUTING.md

Merge Checklist

While we perform many automated checks before auto-merging, some manual checks are needed:

  • A Frontend Frameworks Design member has reviewed these changes
  • There are no unaddressed comments - this check can be automated if reviewers use the "Request Changes" feature
  • For release PRs - Version metadata in Rosie comment is correct

@aviary2-wf
Copy link

Security Insights

No security relevant content was detected by automated scans.

Action Items

  • Review PR for security impact; comment "security review required" if needed or unsure
  • Verify aviary.yaml coverage of security relevant code

Questions or Comments? Reach out on Slack: #support-infosec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was moved to the utils directory and generalized to take a package name argument

Copy link
Contributor Author

@sydneyjodon-wk sydneyjodon-wk Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same file that I moved from the unused_wsd_importer file in the mui_suggestors - I don't know why GitHub doesn't think so

@sydneyjodon-wk
Copy link
Contributor Author

ooo great catches @kealjones-wk - they were pretty straightforward fixes so I just went ahead and updated the codemod to address those! Thank you for catching those!

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some #nits, really only one that would potentially be addressed.

  • Changes look good
  • Tests look good
  • Worked well when I tested it locally

+10

lib/src/unify_package_rename_suggestors/constants.dart Outdated Show resolved Hide resolved
import 'package:react_material_ui/react_material_ui.dart';

content() {
// FIXME(unify_package_rename) Check what theme provider is wrapping this component: if it is a UnifyThemeProvider, remove this FIXME - no action is required; otherwise, migrate this component back to Web Skin Dart.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#nit it looks like this fixme insertion isn't idempotent, but the idempotency tests are passing because on the second run, the unify. references are unresolved because the imports hadn't been updated.

I don't think this is worth fixing since it's so uncommon, but I thought I'd call it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's a good catch! Okay I'll keep that in mind and try not to re-run the codemod too much

// (which is more common for the WSD context), it fails here instead of failing the first test.
setUpAll(resolvedContext.warmUpAnalysis);

group('UnifyRenameSuggestor', () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#nit It makes me a bit nervous that we're not testing the import renaming and the usage renaming together, to ensure they're in sync with what they update.

But, I don't think we have an easy way of testing codemod sequences, and I don't think it'd be worth trying to set that up.

Perhaps if they were updated within the same suggestor, then that'd enable easier testing. But again, I'm not sure refactoring it would be worth it.

kealjones-wk
kealjones-wk previously approved these changes Oct 30, 2023
Copy link
Contributor

@kealjones-wk kealjones-wk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+10

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+10 refresh

@greglittlefield-wf
Copy link
Contributor

Merging once CI passes

@Workiva/release-management-p

Copy link
Contributor

@kealjones-wk kealjones-wk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing... might not matter...

mainLibraryUnitResult.unit, mainLibraryUnitResult.lineInfo);
yield Patch(
insertInfo.leadingNewlines +
"import '${importInfo.uri}'${importInfo.namespace != null ? ' as ${importInfo.namespace}' : ''};" +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just throwing this out there that this doesnt seem to retain show statements

example:
import 'package:react_material_ui/styles/theme_provider.dart' as mui_theme show UnifyThemeProvider;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh good catch! Yeah I think it'd be worth updating so this retains show and hide

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Copy link
Contributor

@kealjones-wk kealjones-wk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+10

Copy link

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 from RM

@rmconsole3-wf rmconsole3-wf merged commit 60ae76b into master Oct 31, 2023
4 checks passed
@rmconsole3-wf rmconsole3-wf deleted the FED-570-unify-package-rename branch October 31, 2023 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants